package ls.controller;

import ls.model.Moaning;
import ls.repository.MoaningRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.ModelAndView;

public abstract class BaseController {
    protected static final String ATTR_MOANING = "moaning";
    protected static final String ATTR_REPLIES = "replies";
    protected static final String ATTR_READ_ONLY = "readOnly";
    private MoaningRepository moaningRepository;

    @Autowired
    public void setMoaningRepository(MoaningRepository moaningRepository) {
        this.moaningRepository = moaningRepository;
    }

    public MoaningRepository getMoaningRepository() {
        return moaningRepository;
    }

    protected void putMoaning(ModelAndView view, Moaning moaning) {
        view.addObject(ATTR_MOANING, moaning);
    }

    protected void putReadOnly(ModelAndView view, boolean flag) {
        view.addObject(ATTR_READ_ONLY, flag);
    }
}